package com.du.integration.server.handle.filter;

import lombok.Data;

import java.util.regex.Pattern;

/**
 * @Desc :
 * @Author: shuangdu
 * @date : 2024/1/9
 */
@Data
public class RegexTopicFilter implements MqttTopicFilter {

    private final Pattern regex;

    public RegexTopicFilter(String regex) {
        this.regex = Pattern.compile(regex);
    }

    @Override
    public boolean filter(String topic) {
        return regex.matcher(topic).matches();
    }
}
